import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

const store=new Vuex.Store({
    state:{
      javacount:0, //java的初识票数
      pythoncount:0, //python的初识票数
      phpcount:0 //php的初识票数
    },
    mutations:{
      //投票方法
      addjavacount(state){
        state.javacount+=1
      },
      addpythoncount(state){
        state.pythoncount+=1
      },
      addphpcount(state){
        state.phpcount+=1
      }
    },
    //getters为vuex当中的计算属性
    getters:{
      //计算总票数
      sumcount(state){
        return state.javacount+state.phpcount+state.pythoncount
      }
    }
})


export default store;